package com.deworkes.admin.web.vo;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class Result<T> implements Serializable {
    private static final String SUCCESS_CODE = "0000";
    private static final String SUCCESS_MSG = "success";
    private String code;
    private String message;
    private T data;

    public static <T> Result<T> success(T data) {
        return (Result<T>) Result.builder().code(SUCCESS_CODE).message(SUCCESS_MSG).data(data).build();
    }

    public static Result error(String code, String message) {
        return Result.builder().code(code).message(message).build();
    }
}
